package com.spring.boot.controller;

import com.spring.boot.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;

@Slf4j
@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 2.开启定时任务
public class TimedTask {
    @Autowired
    private ContractService contractService;
    //每天凌晨0点 定时同步过期合同和保单信息
    @Scheduled(cron = "0 0 0 */1 * ?")
    //间隔五秒
    //@Scheduled(fixedRate = 5000)
    private void configureTasks() {
        //打印日志
        log.error("定时任务开启");
        contractService.synchronizationExpiration();
    }
}
